package lc.字符串;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/17
 */
public class Math5902_检查句子中的数字是否递增 {

    public static boolean areNumbersAscending(String s) {

        int t = 0;
        char[] chars = s.toCharArray();
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < chars.length; i++) {

            // 最后一个是数字就会漏加
            if (chars[i] >= '0' && chars[i] <= '9') {
                t = 10 * t + chars[i] - '0';
            }

            else {
                if (t > 0) {
                    list.add(t);
                }
                t = 0;
            }
        }

        if (t > 0) {
            list.add(t);
        }
        list.forEach((x) -> System.out.println(x));
        for (int i = 1; i < list.size(); i++) {
            if (list.get(i) <= list.get(i - 1)) {
                return false;
            }
        }
        return true;


    }



}
